package com.pet.framework.constant;

public class Tree<T> {

	public TreeNode<T> root;
	
	public void addNode(TreeNode<T> node,T newNode){
		if(null==node){
			if(null==root){
				root = new TreeNode<T>(newNode);
			}
		}else{
			TreeNode<T> temp = new TreeNode<T>(newNode);
			node.nodelist.add(temp);
		}
	}
	public TreeNode<T> findNode(T newNode){
		return searchNode(root, newNode);
	}
	public TreeNode<T> searchNode(TreeNode<T> input,T newNode){
		TreeNode<T> temp = null;
		
		if(input.t.equals(newNode)){
			return input;
		}
		
		for(int i = 0; i < input.nodelist.size(); i++){
			temp = searchNode(input.nodelist.get(i), newNode);
			if(null!=temp){
				break;
			}
		}
		return temp;
	}
	
	
	
}
